package com.zhouheng.springbootmultithreading.module.bankaccount.atm;

import com.zhouheng.springbootmultithreading.module.bankaccount.entity.BankAccountVo;
import com.zhouheng.springbootmultithreading.common.utils.HttpRequestUtils;
import com.zhouheng.springbootmultithreading.common.utils.JsonUtil;


public class AtmFindMoney extends Thread {

    private String atmName;
    private String url;
    private String account;
    private String password;

    public AtmFindMoney(String atmName, String url, String account, String password){
        this.atmName = atmName;
        this.url = url;
        this.account = account;
        this.password = password;
    }

    @Override
    public void run() {
        this.findMoney();
    }

    private void findMoney()  {
        BankAccountVo bankAccountVo = new BankAccountVo();
        bankAccountVo.setAccount(account);
        bankAccountVo.setPassword(password);
        String param = JsonUtil.toJson(bankAccountVo);
        try{
            String result = HttpRequestUtils.httpPostString(url,param);
            System.out.println(System.currentTimeMillis() +" "+ atmName+"查询余额为:"+result);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }

}
